<?php
// +----------------------------------------------------------------------------
// | PHP@妖孽 [三十年河东三十年河西,莫欺少年穷.!]
// +----------------------------------------------------------------------------
// | Copyright (c) 2015 http://www.itdaodan.com All rights reserved.
// +----------------------------------------------------------------------------
// | Author: PHP@妖孽 <dino_ma@163.com>
// +----------------------------------------------------------------------------
/**
 *@todo 活动模型
 +------------------------------------------------------------------------------
 * @version   1.0
 * @since 2015-8-17
 +------------------------------------------------------------------------------
 */
namespace Home\Controller;
use Home\Controller;
class ActivityController extends HomeController {

	
	/**
	 * @todo 活动
	 * @param int id 活动id
	 * @author PHP@妖孽<dino_ma@163.com>
	 */
	public function index(){
		$activity_id = (int)I('id');
		if($activity_id==0){
			$this->error('参数有误哦.~');
		}
		$obj = D('Admin/Activity','Service');
		if($html = $obj->getActivityContent($activity_id)){
			$this->show($html);
		}else{
			$this->error($obj->getError());
		}
	}
	
	/**
	 * @todo 活动报名
	 * @param int id 活动id
	 * @author PHP@妖孽<dino_ma@163.com>
	 */
	public function join(){
		$obj = D('Admin/Activity','Service');
		if($a = $obj->joinActivity($_REQUEST,1)){
			$this->success('欢迎您报名哈尔滨家家户户网'.getActivityName(I('activity_id')).'活动,如有问题可以致电咨询电话400-8168-333。');
		}else{
			$this->error($obj->getError());
		}
	}
	
	/**
	 * @todo 获取报名人的总数
	 * @param int id 活动id
	 * @author PHP@妖孽<dino_ma@163.com>
	 */
	public function getActivityNum(){
		$activity_id = (int)I('id');
		if($activity_id==0){
			$this->error('参数有误哦.~');
		}
		$num = D("Admin/Activity","Service")->getActivityConsumer($activity_id);
		$this->ajaxReturn(array('status'=>1,'num'=>(int)$num));
	}
	
}